﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;

namespace Krist_em_up.Components
{
    public class Souris : GameComponent
    {
        MouseState prevState, state;
        public Souris(Game game)
            : base(game)
        {
            state = Mouse.GetState();
        }
        /*
         * Renvoie les coordonnées de la souris
         */
        public Vector2 getCoord()
        {
            return new Vector2(state.X, state.Y);
        }
        
        /// <summary>
        /// Check if the use has left-clicked
        /// </summary>
        /// <returns></returns>
        public bool LeftClicked()
        {
            return ((state.LeftButton == ButtonState.Released)
                && (prevState.LeftButton == ButtonState.Pressed));
            
        }
        /**
         * Update the states
         */ 
        public override void Update(GameTime gameTime)
        {
            prevState = state;
            state = Mouse.GetState();
            base.Update(gameTime);
        }
    }
}
